NSArray *segmentedArray = [[NSArray alloc]initWithObjects:@"热门",@"广场",@"关注",nil];
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc]initWithItems:segmentedArray];
segmentedControl.frame =CGRectMake(0.0f, 0.0f, 150.0f, 30.0f);
[segmentedControl addTarget:self action:@selector(SelectbuttonAction:) forControlEvents:UIControlEventValueChanged];
segmentedControl.layer.borderWidth = 0.0;
segmentedControl.selectedSegmentIndex=0;
segmentedControl.tintColor = [UIColor colorWithRed:0.69f green:0.75f blue:0.87f alpha:1.00f];
segmentedControl.backgroundColor = [UIColor clearColor];
self.navigationItem.titleView = segmentedControl;
-(void)SelectbuttonAction:(UISegmentedControl *)seg{
NSInteger Index = seg.selectedSegmentIndex;
switch (Index) {
case 0:
break;
case 1:
break;
case 2:
break;
default:
break;
}
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。